package com.github.jeffreyning.mybatisplus.demo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.github.jeffreyning.mybatisplus.anno.InsertFill;
import com.github.jeffreyning.mybatisplus.anno.UpdateFill;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Date;

@KeySequence("select lpad(max(seqno)+3,10,'0') from test")
@TableName(value = "test")
@Data
@EqualsAndHashCode(callSuper = false)
public class TestEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type=IdType.INPUT)
    private Integer id;

    @TableField(value="seqno",fill=FieldFill.INSERT )
    @InsertFill("select lpad(max(seqno)+3,10,'0') from test")
    private String seqno;

    //@InsertFill("select now()")
    @TableField(value="create_time",fill=FieldFill.INSERT)
    private Date createTime;

    @InsertFill("select now()")
    @UpdateFill("select now()")
    @TableField(value="update_time",fill=FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @TableField("some")
    private String some;


}
